package world.criver.imagecompresstool.application;

import javafx.application.Application;
import javafx.event.Event;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import world.criver.imagecompresstool.data.daConfig;
import world.criver.imagecompresstool.data.daFxml;
import world.criver.imagecompresstool.data.daMaterial;
import world.criver.imagecompresstool.data.daValue;
import world.criver.imagecompresstool.function.funLock;
import world.criver.imagecompresstool.function.funReg;
import world.criver.imagecompresstool.function.funTray;

public class appMaster extends Application {
    public appMaster(){
        daValue.iniBinUrl();
        funLock lock=new funLock();
        lock.clip(daValue.commands);
        if(lock.exist())System.exit(0);
        daConfig.load();
        new funReg().change();
        funTray tray=new funTray();
        tray.keepAlive();
        tray.iniPopMenu();
        tray.iniTray();
    }
    @Override
    public void start(Stage stage) throws Exception {
        Scene sc= new Scene(daFxml.master.load());
        sc.setFill(null);
        stage.setScene(sc);
        stage.setTitle("图片压缩工具:v1.1.1 SolitaryWayfarer");
        stage.getIcons().add(daMaterial.icon_32x32);
        stage.initStyle(StageStyle.TRANSPARENT);
        if(daConfig.show_master)stage.show();
        daValue.master=stage;
        stage.setOnCloseRequest(Event::consume);
    }
    public static void _main(String[] args){
        daValue.commands=args;
        launch();
    }
}
